package cn.zmit.kuxi.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.zmit.kuxi.R;
import cn.zmit.kuxi.entity.LuckNumEntity;

public class LuckyNumberAdapter extends BaseAdapter {
	public List<LuckNumEntity> mCellDataList;
	public Context mContext;

	public LuckyNumberAdapter(List<LuckNumEntity> celldatalist, Context context) {
		this.mCellDataList = celldatalist;
		this.mContext = context;
	}

	@Override
	public int getCount() {
		return mCellDataList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return mCellDataList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		View view;
		ViewHolder holder;
		if (convertView != null) {
			view = convertView;
			holder = (ViewHolder) view.getTag();
		} else {
			view = View.inflate(mContext, R.layout.item_lucky_info, null);
			holder = new ViewHolder();
			holder.tv_phase = (TextView) view.findViewById(R.id.tv_phase);
			holder.tv_luck_num = (TextView) view
					.findViewById(R.id.tv_lucky_num);
			holder.tv_goods_info = (TextView) view
					.findViewById(R.id.tv_goods_info);
			view.setTag(holder);
		}
		holder.tv_phase.setText("第" + mCellDataList.get(position).getPhase()
				+ "期");
		holder.tv_phase.setTextColor(Color.parseColor("#FF0000"));
		holder.tv_luck_num.setText("幸运号："
				+ mCellDataList.get(position).getLucky_number());
		holder.tv_goods_info.setText(mCellDataList.get(position)
				.getGoods_info());
		return view;
	}

	static class ViewHolder {
		TextView tv_phase;
		TextView tv_luck_num;
		TextView tv_goods_info;
	}

}
